#include "../CShortRouteActualCostCalculator.h"

#include "astar/private/map.h"

#include <math.h>

CShortRouteActualCostCalculator::CShortRouteActualCostCalculator()
{
}

CShortRouteActualCostCalculator::~CShortRouteActualCostCalculator()
{
}

bool CShortRouteActualCostCalculator::calculate(const key & k, cost & cst)
{
   int x = 0;
   int y = 0;
   Key2XY(k, x, y);
   switch(gMap[x][y])
   {
   case 'o':
      cst = static_cast<cost>(100);
      break;
   case '=':
      cst = static_cast<cost>(60);
      break;
   default:
      cst = static_cast<cost>(-1);
         break;
   }
   return true;
}

bool CShortRouteActualCostCalculator::calculate(const key & k, const key & nk, cost & cst)
{
   int iCurX = 0;
   int iCurY = 0;
   int iNextX = 0;
   int iNextY = 0;
   Key2XY(k, iCurX, iCurY);
   Key2XY(nk, iNextX, iNextY);

   cst = abs(iCurX - iNextX) + abs(iCurY - iNextY);

   return true;
}
